package org.jcommon.com.util.webservice;

import java.rmi.RemoteException;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;

public class WebserviceRequest implements Runnable{

	private Call call;
	private WebserviceListener listener;
	private Object[] params;
	
	public WebserviceRequest(WebserviceListener listener, Call call, Object[] params){
		this.listener = listener;
		this.call = call;
		this.params = params;
	}
	
	public void run() {
		// TODO Auto-generated method stub
		try {
			if(call!=null)
				listener.onSuccessful(this, this.call.invoke(params));
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			listener.onException(this, e);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			listener.onTimeout(this);
		}
	}

}
